package com.xiongjie.SingleCache.service;

import com.xiongjie.SingleCache.Interface.impl.ISingleCacheImpl;
import com.xiongjie.SingleCache.entity.SingleCacheEntity;
import org.infinispan.Cache;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class RSingleCacheService extends ISingleCacheImpl {

   final Random random;

   public RSingleCacheService(Cache<String, SingleCacheEntity> cache) {
      super(cache);
      random = new Random();
   }

   @Override
   protected SingleCacheEntity getSingleCacheEntity(String name) {
      try {
         TimeUnit.MILLISECONDS.sleep(200);
      } catch (InterruptedException e) {

      }
      return new SingleCacheEntity(name.trim(),name+random.nextFloat());
   }

}
